USE [SONALIKA_BGK_UPDATED]
GO

/****** Object:  StoredProcedure [dbo].[SpSparePurchaseRpt]    Script Date: 05/25/2014 16:39:18 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[SpSparePurchaseRpt]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[SpSparePurchaseRpt]
GO

USE [SONALIKA_BGK_UPDATED]
GO

/****** Object:  StoredProcedure [dbo].[SpSparePurchaseRpt]    Script Date: 05/25/2014 16:39:18 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO




CREATE PROC [dbo].[SpSparePurchaseRpt] 
(@FROM_DATE DATETIME,
@TO_DATE DATETIME)
AS
BEGIN
SELECT 
        INVOICE_ID
       ,INVOICE_NO
       ,replace(convert(NVARCHAR, INVOICE_DATE, 106), ' ', '-')AS INVOICE_DATE 
       ,INVOICE_GRANDTOTAL
      
 FROM INVOICE I
  WHERE PURCHASE_TYPE IN(SELECT MASTER_ID FROM MASTER WHERE MASTER_VALUE='SPARE' OR MASTER_VALUE='LUBRICANT')AND(INVOICE_DATE BETWEEN @FROM_DATE AND @TO_DATE)
     
END



GO


